import { Injectable } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators';


const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json',
    'Authorization': 'my-auth-token'
  })
};


@Injectable({
  providedIn: 'root'
})

export class Test08Service {
  constructor(private http:HttpClient) { }

  getdata_post(){
    let header = new HttpHeaders({
      'Content-Type':  'application/json',
      'jwt': 'hang_eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNTU5MTI4MzEzfQ.ZSsz3PmwxF8SZC07cCu4mfuMENI28H21_8ZC-4L9btj4bvt9mJR0fKWejlrgIf6Trz3uthoGgdO8qHlYrDeQSg'
    });


    console.log('请求数据');
    var url="http://localhost:9999/ExpressRegion/listPage";
    this.http.post(url,{},{"headers":header}).subscribe(function(data){
      console.log("-----ok-------");
      console.log(data);
    },function(err){
      console.log(err);
    })
  }
  getdata(){
    console.log('请求数据');
    var url="http://localhost:9999/jwt/set/1";
    this.http.get(url).subscribe(function(data){
      console.log("-----ok-------");
      console.log(data);
    },function(err){
      console.log(err);
    })
  }
  getdata_remote(){
    console.log('请求数据');
    var url="http://mall.center.weihaoran.cn/api/jwt/set/1";
    this.http.get(url).subscribe(function(data){
      console.log("-----ok-------");
      console.log(data);
    },function(err){
      console.log(err);
    })
  }

  getdata_cros(){
    console.log('------请求cross数据-----------');
    console.log('请求cross数据');

    let header = new HttpHeaders({
      'Content-Type':  'application/json',
      'jwt': 'hang_eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNTU5MTI4MzEzfQ.ZSsz3PmwxF8SZC07cCu4mfuMENI28H21_8ZC-4L9btj4bvt9mJR0fKWejlrgIf6Trz3uthoGgdO8qHlYrDeQSg'
    });

    var url="http://mall.center.weihaoran.cn/api/Area/1";
    this.http.get(url,{headers:header}).subscribe(function(data){
      console.log("-----ok-------");
      console.log(data);
    },function(err){
      console.log(err);
    })
  }
  getdata_cros_local(){
    console.log('------请求cross数据-----------');
    console.log('请求cross数据');

    let header = new HttpHeaders({
      'Content-Type':  'application/json',
      'jwt': 'hang_eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNTU5MTI4MzEzfQ.ZSsz3PmwxF8SZC07cCu4mfuMENI28H21_8ZC-4L9btj4bvt9mJR0fKWejlrgIf6Trz3uthoGgdO8qHlYrDeQSg'
    });

    var url="http://localhost:9999/Area/1";
    this.http.get(url,{"headers":header}).subscribe(function(data){
      console.log("-----ok-------");
      console.log(data);
    },function(err){
      console.log(err);
    })
  }



}
